package br.com.fiap.goaround.servlet;

import java.io.IOException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import br.com.fiap.goaround.bo.TrafficBO;

@SuppressWarnings("serial")
public class TrafficSearchServlet extends HttpServlet{
	
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws IOException {

		String requisicao = req.getParameter("acao");
		if(requisicao.equalsIgnoreCase("delete")){
			TrafficBO tran = new TrafficBO();
			tran.deleteAll();
		} else {
			TrafficBO tran = new TrafficBO();
			try {
				boolean exec = tran.updateBase();
				if (exec == true)
					System.out.println("Atualização de base com sucesso!");
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		resp.sendRedirect("/lista.jsp");
	}

}
